How do I customize my app so the fonts and colors match my university’s?
Requires you to know at least some CSS
Each color value appears in multiple places
Need to install 2 packages (requires shiny>=1.6)
sass: compile sass to css in R
bslib: customize Bootstrap in R
https://rstudio.github.io/bslib/
Unfortunately doesn’t work with Shiny Dashboards – use fresh instead!
https://dreamrs.github.io/fresh/articles/vars-shinydashboard.html
bs_theme objecttheme to your bs_theme object in the
UIlibrary(shiny)
library(bslib) # step 1
my_theme <- bs_theme() # step 2
ui <- fluidPage(
theme = my_theme, # step 3
...
)
bs_themer() to your server functionlibrary(shiny)
library(bslib) # step 1
...
server <- function(input, output){
bs_themer()
##cool reactive logic##
}
When you make changes in the Preview tool, code for updating your theme is printed to the console. Copy the updates to your Shiny app.
my_theme <- bs_theme()
# This line is copied from the console (may need to update theme name)
my_theme <- bs_theme_update(my_theme, bg = "#4B3E23", fg = "#000000")
List of Bootstrap sass variables:
bslib commands: https://rstudio.github.io/bslib/reference/index.html
The thematic package enables automatic theming of
plots
library(thematic)
thematic_on()
onStop(thematic_off)